window.onload = function () {
    let  useArr  = JSON.parse(localStorage.getItem('ledgerUsers') || [])
    const img = document.querySelector('.set a img')
    const allow = document.querySelector('.allow')
    const ball = document.querySelector('.ball')
    const active = document.querySelector('.active')
    let item = ''
    useArr.find(function (items, index) { 
        item = items.flag;
    })
    flag = item
    console.log(flag);
    img.addEventListener('touchstart',function(){
        location.href = './系统设置.html'
    })
    if(flag){
        ball.classList.add('active')
        allow.style.background = '#EF4F3F';
       }else{
        ball.classList.remove('active')
        allow.style.background = '#EDEDED';
       }

    ball.addEventListener('touchstart',function(){
      if(ball.classList.contains('active')){
        ball.classList.remove('active')
        allow.style.background = '#EDEDED';
        flag = false
        useArr.find(function (items, index) { 
          items.flag = flag;
      })
        localStorage.setItem("ledgerUsers", JSON.stringify(useArr))
       }else{
        allow.style.background = '#EF4F3F';
        ball.classList.add('active')
        flag = true
        useArr.find(function (items, index) { 
          items.flag = flag;
      })
        localStorage.setItem("ledgerUsers", JSON.stringify(useArr))
     }
    })
}